import { observable, action,makeObservable } from 'mobx';
import moment from "moment";
import { currentUser } from "@/services/auth";
import GlobalFunctions from '@/store/globalFunctions';

class ContractSuspendModel {
    @observable id= 0;//
    @observable userid=currentUser.id;//--操作员ID
    @observable bill_date=moment();//--申请日期
    @observable contractsid= "";
    @observable code= "";//----合同编号
    @observable name= "";//--合同名称
    @observable status= 0;//--状态
    @observable message= "";//--纪录事项
    @observable employeeid="";
    @observable departmentid=currentUser.orgunit_id;
    @observable sourcetype= "";
    @observable sourceid= 0;
    //===================   
    @observable isnew= true;
    @observable isedit=true;
    @observable allow_col=[];
    @observable colcontrol=false;

    constructor(id) {
        this.id=id;       
        makeObservable(this);
    }
    
    @action setUserid(userid) {
        this.userid = userid;
    }
    @action setBill_date(bill_date) {
        this.bill_date = bill_date;
    }
    @action setBilledit(item) {
        this.isedit = item.edit;
        this.allow_col = item.allow_col;
        this.colcontrol = item.colcontrol;
    }
    @action setContractsid(data) {
        this.contractsid = data.id;
        this.departmentid= data.departmentid;
        this.code= data.code;//----合同编号
        this.name= data.name;//--合同名称
    }
    @action setCode(code) {
        this.code = code;
    }
    @action setName(name) {
        this.name = name;
    }
    @action setStatus(status) {
        this.status = status;
    }
    @action setMessage(message) {
        this.message = message;
    }
    @action setEmployeeid(employeeid) {
        this.employeeid = employeeid;
    }
    @action setDepartmentid(departmentid) {
        this.departmentid = departmentid;
    }
    @action setSourcetype(sourcetype) {
        this.sourcetype = sourcetype;
    }
    @action setSourceid(sourceid) {
        this.sourceid = sourceid;
    }

    static fromJS(obj) {
        let m =  new ContractSuspendModel(obj.id);
        m.userid= obj.userid ;
        m.bill_date= moment(obj.bill_date);//--申请日期
        m.contractsid= obj.contractsid ;
        m.code= obj.code ;//----合同编号
        m.name= obj.name ;//--合同名称
        m.status= obj.status ;//--状态
        m.message= obj.message ;//--纪录事项
        m.employeeid=obj.employeeid ;
        m.departmentid=obj.departmentid ;
        m.sourcetype= obj.sourcetype ;
        m.sourceid= obj.sourceid ;
        m.isnew= false;
        return m;
    }
}

export default ContractSuspendModel;